package acmCoder;

import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * http://blog.csdn.net/xiao_dondon/article/details/77489262
 * Created by shuowu on 2017/10/20.
 */
public class TurpleSort {

    static final int MAX = 100002;
    int n = 0;

    private Point[] points = new Point[MAX];
    //二元排序
    public static void main(String[] args){
        TurpleSort object = new TurpleSort();
        object.getRes();
    }

    public void getRes(){
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        while(scanner.hasNext()){
            n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                points[i] = new Point(x, y);
            }
            Arrays.sort(points, 0, n, new Comparator<Point>() {
                @Override
                public int compare(Point point1, Point point2) {
                    //逆序排序
                    return point2.x - point1.x;
                }
            });
            int res = 0;
            int curMin = points[0].y;
            for(int i = 1 ; i < n; i++){
                if(points[i].y < curMin){
                    res++;
                } else{
                    curMin = points[i].y;
                }
            }
            System.out.println(res);
        }
    }

    class Point{
        public int x;
        public int y;
        Point(int x, int y){
            this.x = x;
            this.y = y;
        }
    }
}
